#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
using namespace std;

int main()
{
// // int pd = open("my_open_t.txt", O_RDWR | O_CREAT, 0666);
////int pd = open("my_open_t.txt", O_CREAT | O_WRONLY | O_TRUNC, 0666);
//  int pd = open("my_open_t.txt",O_RDONLY);
//  if (pd < 0)
//  {
//    perror("open fault:");
//    exit(-1);
//  }
//  cout << "success" << endl;
// const char* s1 = "hello write\n";  
// write(pd, s1, strlen(s1)); //C语言中，字符串的长度会包含\0，但在操作系喔中不用考虑。
//  
//  char ro[64];
//  memset(ro, '\0', sizeof ro);
//  read(pd, ro, sizeof(ro));
//  printf("%s", ro);
//

// int pd1 = open("my_open_t.txt", O_RDWR | O_CREAT, 0666);
// cout << "my_open pd:" << pd1 << endl;
// int pd2 = open("my_open_t.txt", O_RDWR | O_CREAT, 0666);
// cout << "my_open pd:" << pd2 << endl;
// int pd3 = open("my_open_t.txt", O_RDWR | O_CREAT, 0666);
// cout << "my_open pd:" << pd3 << endl;
// int pd4 = open("my_open_t.txt", O_RDWR | O_CREAT, 0666);
// cout << "my_open pd:" << pd4 << endl;
  
  close(1);
  int fd = open("my_open_t.txt", O_RDWR | O_APPEND);
  cout << "fd : " << fd << endl;
  cout << "fd cout_success" << endl;
  printf(" fd printf\n"); 
  return 0;
}



